// 导入 http 模块
const http = require("http");

// 创建服务对象
const server = http.createServer((request, response) => {
  // 设置响应状态码
  response.statusCode = 203;
  // 设置响应状态描述
  response.statusMessage = "I love you!";
  // 设置响应头
  response.setHeader("content-type", "text/html;charset=utf-8");
  response.setHeader("Server", "nodejs");
  response.setHeader("Myheader", "test");
  response.setHeader("MultiHeader", ["h1", "h2", "h3"]);
  // 设置响应体
  response.write("响应体");
  response.end("设置响应报文");
});

// 监听端口，启动服务
server.listen(9000, () => {
  console.log("服务已经启动……");
});
